//
//  ViewController.swift
//  FontSet
//
//  Created by Wei Zhou on 2017/3/23.
//  Copyright © 2017年 Wulian. All rights reserved.
//

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    @IBOutlet weak var tableview: UITableView!

    var fontArr : [String] = UIFont.familyNames
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        print("Get print:+ \(#file) -- \(#line) --\(#function)")
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return fontArr.count
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return UIFont.fontNames(forFamilyName: fontArr[section]).count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "FontCellID")
        cell?.textLabel?.text = "hello font ABCD efg 1234567890 !,.$# ！。， 太极两仪"
        cell?.textLabel?.numberOfLines = 0
        let fontName = UIFont.fontNames(forFamilyName: fontArr[indexPath.section])[indexPath.row]
        cell?.textLabel?.font = UIFont.init(name: fontName, size: 18.0)
        cell?.detailTextLabel?.text = fontName
        cell?.detailTextLabel?.textColor = #colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1)
        return cell!
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

